package com.bjsxt.base.sync_shuoGG;

import java.text.SimpleDateFormat;
import java.util.Date;

/*
现象: A线程运行test1期间, B线程也可以运行test1, 之间互不干扰, 因为AB线程均有自己的NormalUtil对象, 而test1用对象锁
输出结果:
    main UseLock NormalUtil.test1 09:11:19
    Thread-0 ThreadNormal1 09:11:19
    Thread-0 UseLock NormalUtil.test1 09:11:19
    main ReleaseLock NormalUtil.test1 09:11:24
    Thread-0 ReleaseLock NormalUtil.test1 09:11:24
*/
public class ThreadNormal1 extends Thread {

    @Override
    public void run() {
        System.out.println(currentThread().getName() + " ThreadNormal1 " + new SimpleDateFormat("HH:mm:ss").format(new Date()));
        new NormalUtil().test1();
    }

    public static void main(String[] args) {
        new ThreadNormal1().start();
        new NormalUtil().test1();
    }
}
